Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add mock data #393

Merged
merged 2 commits into from
Dec 11, 2024
Merged

chore: add mock data #393

merged 2 commits into from
Dec 11, 2024

Conversation

ByteZhang1024
Copy link
Contributor

@ByteZhang1024 ByteZhang1024 commented Dec 11, 2024

Summary by CodeRabbit

  • 新功能

    • 引入了新的 MenuListItem 组件,用于渲染菜单列表项,支持国际化和交互功能。
    • 添加了 btcSignPsbt 方法,用于签署部分签名比特币交易(PSBT),扩展了比特币交易的功能。
  • 变更

    • 移除了 Header.tsx 中的 MenuItem 接口,改为使用外部导入的 MenuItemMenuListItem

Copy link

coderabbitai bot commented Dec 11, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

此次变更涉及Header.tsxMenuListItem.native.tsxMenuListItem.tsx文件。Header.tsx中移除了本地定义的MenuItem接口,改为从MenuListItem模块导入。MenuListItem组件在Header.tsx中被完全移除,功能已整合到新的导入中。新文件MenuListItem.native.tsxMenuListItem.tsx定义了MenuListItem组件,使用tamagui库的ListItem组件,并引入了MenuItem接口,提供了菜单项的结构和交互功能。bitcoin.ts文件中新增了btcSignPsbt方法,用于签名部分签名比特币交易(PSBT)。

Changes

文件路径 更改摘要
src/components/ui/Header.tsx 移除MenuItem接口;更新MenuListItem方法;添加import { MenuItem, MenuListItem }
src/components/ui/MenuListItem.native.tsx 新增MenuListItem组件和MenuItem接口;使用tamagui库的ListItem组件。
src/components/ui/MenuListItem.tsx 新增MenuListItem组件和MenuItem接口;使用react-intl库的useIntl进行国际化处理。
src/data/bitcoin.ts 新增btcSignPsbt方法,包含描述和两个签名PSBT的场景。

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 260e7a7 and 3fc23ef.

📒 Files selected for processing (1)
  • packages/connect-examples/expo-example/src/testTools/securityCheckTest/blindSignature/index.tsx (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range comments (3)
packages/connect-examples/expo-example/src/components/ui/Header.tsx (3)

Line range hint 12-19: 建议将菜单配置移至配置文件

建议将 menuItems 数组移至单独的配置文件,便于维护和修改。

-const menuItems: MenuItem[] = [
-  { route: Routes.Payload, labelId: 'tab__api_payload' },
-  { route: Routes.FirmwareUpdateTest, labelId: 'tab__firmware_update' },
-  ...
-];
+import { menuItems } from './config/menu-items';

Line range hint 71-82: 简化媒体查询逻辑

当前的媒体查询逻辑较为复杂,建议使用数组方法简化。

-  const { visibleItems, dropdownItems } = useMemo(() => {
-    if (media.gtXxl)
-      return { visibleItems: menuItems.slice(0, 10), dropdownItems: menuItems.slice(10) };
-    if (media.gtXl)
-      return { visibleItems: menuItems.slice(0, 9), dropdownItems: menuItems.slice(9) };
+  const { visibleItems, dropdownItems } = useMemo(() => {
+    const breakpoints = [
+      { condition: media.gtXxl, visibleCount: 10 },
+      { condition: media.gtXl, visibleCount: 9 },
+      { condition: media.gtLg, visibleCount: 7 },
+      { condition: media.gtMd, visibleCount: 5 },
+      { condition: media.gtSm, visibleCount: 3 },
+      { condition: media.gtXs, visibleCount: 2 },
+    ];
+    
+    const { visibleCount = 0 } = breakpoints.find(bp => bp.condition) ?? {};
+    return {
+      visibleItems: menuItems.slice(0, visibleCount),
+      dropdownItems: menuItems.slice(visibleCount),
+    };
+  }, [media]);

Line range hint 84-143: 建议拆分组件以提高可维护性

HeaderView 组件职责过多,建议将 Sheet 相关逻辑抽取为独立组件。

建议将 Sheet 部分抽取为 MenuSheet 组件,这样可以:

  1. 降低主组件复杂度
  2. 提高代码可读性
  3. 便于单独测试 Sheet 功能
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between d76e7fe and 260e7a7.

📒 Files selected for processing (4)
  • packages/connect-examples/expo-example/src/components/ui/Header.tsx (1 hunks)
  • packages/connect-examples/expo-example/src/components/ui/MenuListItem.native.tsx (1 hunks)
  • packages/connect-examples/expo-example/src/components/ui/MenuListItem.tsx (1 hunks)
  • packages/connect-examples/expo-example/src/data/bitcoin.ts (1 hunks)
🔇 Additional comments (2)
packages/connect-examples/expo-example/src/components/ui/MenuListItem.native.tsx (1)

3-6: 接口定义清晰简洁

MenuItem 接口设计合理,包含必要的属性。

packages/connect-examples/expo-example/src/data/bitcoin.ts (1)

187-187: 验证 PSBT 数据的有效性

PSBT 数据格式正确,以标准魔术字节开头。建议添加自动化测试以确保数据的有效性。

@ByteZhang1024 ByteZhang1024 enabled auto-merge (squash) December 11, 2024 12:37
@ByteZhang1024 ByteZhang1024 merged commit 300f8dc into onekey Dec 11, 2024
6 of 7 checks passed
@ByteZhang1024 ByteZhang1024 deleted the chore/mockData branch December 11, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants